﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConfigFile
{
    public class GenericFile
    {
        private DoubleKeyDictionary<string, string, string> _Key = new DoubleKeyDictionary<string, string, string>();
        private List<string> _Keys = new List<string>();
        private List<string> _Values = new List<string>();
        private ConfigFile cfg;

        public GenericFile(string file)
        {
            try
            {
                this.cfg = new ConfigFile(file);
                if (this.cfg == null)
                {
                    throw new Exception("Error in Configuration file");
                }
                _Keys = this.cfg.Get_Keys();
                foreach (string str in _Keys)
                {
                    foreach (string str2 in this.cfg.Get_Key(str))
                    {
                        string str3 = cfg.Get_ParamS(str2, 2);
                        string str4 = cfg.Get_ParamS(str2, 1);
                        this._Key.Add(str, str4, str3);
                    }
                   _Values.Add(str);
                }
            }
            catch (InvalidCastException exception)
            {
                throw exception;
            }
        }

        public Dictionary<string, string> GetValue(string Key)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            foreach (DoubleKeyPairValue<string, string, string> value2 in _Key)
            {
                if (value2.Key1 == Key)
                {
                    dictionary.Add(value2.Key2.ToLower(), value2.Value);
                }
            }
            return dictionary;
        }

        public List<string> GetKeys()
        {
            return _Keys;
        }

    }
}
